package com.woniuxy.order.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RattbitMQ {
    public final static String rentHouse = "topic.rent";
    public final static String secondHouse = "topic.second";

    /**
     * 租房队列
     * @return
     */
    @Bean
    public Queue rentQueue() {
        return new Queue(RattbitMQ.rentHouse);
    }

    @Bean
    public TopicExchange exchangeorder() {
        return new TopicExchange("topicExchange");
    }

    @Bean
    Binding bindingExchangeMessage() {
        return BindingBuilder.bind(rentQueue()).to(exchangeorder()).with(rentHouse);
    }


    /**
     * 二手房队列
     */
    @Bean
    public Queue secondQueue(){
        return  new Queue(RattbitMQ.secondHouse);
    }

    @Bean
    Binding bindingSecondQueue(){
        return  BindingBuilder.bind(secondQueue()).to(exchangeorder()).with(secondHouse);
    }


}
